/**
 * 初始化路由信息
 */
const express = require("express");
const userRouter = require("./user.js");
const taskRouter = require("./task.js");
const tokenRoute = require("./token.js");
const { CustomError } = require("../middleware/index.js");
const router = express.Router(); // 创建路由

router.use("/user", userRouter); // 注册用户路由
router.use("/task", taskRouter); // 注册任务路由
router.use(tokenRoute); // 注册token路由

// 404 错误拦截
router.use((req, res, next) => {
  const error = new CustomError("Not Found!", 404);
  next(error);
});

module.exports = router;
